package com.qipay.mapper;

import com.qipay.baas.model.Holiday;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.Date;
import java.util.List;

/**
 * Creator: Yao
 * Date:    2017/12/13
 * For:
 * Other:
 */
public interface HolidayMapper extends com.qipay.baas.mapper.HolidayMapper {

    // Caused by: org.apache.ibatis.binding.BindingException: Parameter 'arg0' not found. Available parameters are [collection, list]
    // 多添加一个参数就可以
    @InsertProvider(type = HolidaySqlProvider.class, method = "save")
    void save(List<Holiday> list, String empty);

    @SelectProvider(type = HolidaySqlProvider.class, method = "findLastByDate")
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="date", property="date", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="is_holiday", property="isHoliday", jdbcType=JdbcType.TINYINT)
    })
    Holiday findLastByDate(Date date);
}
